/*
 * DiskManager.h
 *
 *  Created on: 14-Oct-2013
 *      Author: pridhvi
 */

#ifndef DISKMANAGER_H_
#define DISKMANAGER_H_
#include "../Global/BaseEntity.h"
#include <fstream>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <string>
#include "../DiskManager/FileHandler.h"
#include "../PageLayout/FreePageLinkedList.h"
#include "../dependency/debug.h"
#include "../Global/GlobalVar.h"
#include "../BufferManager/BufferUtility.h"
#include "../Global/StructureHeaders.h"
using namespace std;
class DiskManager : virtual BaseEntity {
FileHandler *fileHandler;
int _fd;
public:
	DiskManager();
	virtual ~DiskManager();

	FileHandler* getFileHandler();

	/************************************ DATABASE FUNCTION CALLS START*********************************/
	/***
	 * used for creating the database and writing initial structures of systable,DBHeader,freeLinkedList etc
	 * here only authorization is given
	 */
	STATUS_CODE createDataBase(string dbName,int noOfPages);

	STATUS_CODE openDataBase(string dbName);

	STATUS_CODE closeDataBase();

	STATUS_CODE dropDataBase(string dbName);

	STATUS_CODE resizeDataBase(int noOfPages);

	STATUS_CODE readPage(int pageSize, char *pageData,int pageNo);

	STATUS_CODE writePage(int pageSize, char *pageData,int pageNo);

	bool IsDBExists(string dbName);

        map<string,int> listDB();
};

#endif /* DISKMANAGER_H_ */
